﻿package plugin.instances.game
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.utils.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.instance.*;
    import plugin.instances.*;
    import uiresource.instances.ui.*;
    import view.mornExtends.*;

    public class UnionCjGame extends HhcjUI implements IInstance
    {

        public function UnionCjGame()
        {
            return;
        }// end function

        public function initShow(param1:Object, param2:Dictionary) : void
        {
            var _loc_3:Object = null;
            txt_rank.text = "0";
            txt_score.text = "0";
            txt_killCount.text = "0";
            list_msg.array = [];
            list_msg.renderHandler = new Handler(this.rankRender);
            if (param2[InstancesPublic.UNIONCOLLECTION])
            {
                _loc_3 = param2[InstancesPublic.UNIONCOLLECTION];
                txt_score.text = _loc_3.myscore > 0 ? (_loc_3.myscore) : (txt_score.text);
                txt_killCount.text = _loc_3.killnum > 0 ? (_loc_3.killnum) : (txt_killCount.text);
            }
            if (param2[InstancesPublic.UNIONCOLLECTIONRANK])
            {
                this.updateShow(InstancesPublic.UNIONCOLLECTIONRANK, param2[InstancesPublic.UNIONCOLLECTIONRANK]);
            }
            shuoming.toolTip = param1.tips.replace(/#""#/g, "\n");
            this.showItem(param1.show);
            return;
        }// end function

        private function showItem(param1:String) : void
        {
            var _loc_2:* = new ItemSplit();
            var _loc_3:* = _loc_2.doSplits(param1, "&", "/", "#");
            list.array = _loc_3[0];
            list.renderHandler = new Handler(this.itemRender);
            return;
        }// end function

        private function itemRender(param1:Component, param2:int) : void
        {
            if (param2 < list.length)
            {
                (param1 as FlashItem).data = list.array[param2];
            }
            return;
        }// end function

        public function updateShow(param1:int, param2:Object) : void
        {
            var _loc_3:int = 0;
            switch(param1)
            {
                case InstancesPublic.TIMECHECKER:
                {
                    txt_time.text = TimeDataFormatUtil.getLeftTime(int(param2));
                    break;
                }
                case InstancesPublic.UNIONCOLLECTION:
                {
                    if (param2.myscore > 0)
                    {
                        _loc_3 = param2.myscore - Number(txt_score.text);
                        if (_loc_3 > 0)
                        {
                            ModelProxy.change("mainui", "bmRunAdd", {type:2, count:_loc_3});
                        }
                    }
                    txt_score.text = param2.myscore > 0 ? (param2.myscore) : (txt_score.text);
                    txt_killCount.text = param2.killnum > 0 ? (param2.killnum) : (txt_killCount.text);
                    break;
                }
                case InstancesPublic.UNIONCOLLECTIONRANK:
                {
                    list_msg.array = param2.uniongatherRankInfo;
                    txt_rank.text = param2.myIndex;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function rankRender(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Label = null;
            var _loc_5:Label = null;
            var _loc_6:Label = null;
            if (param2 < list_msg.length)
            {
                _loc_3 = list_msg.array[param2];
                _loc_4 = param1.getChildByName("rankindex") as Label;
                _loc_5 = param1.getChildByName("username") as Label;
                _loc_6 = param1.getChildByName("killcount") as Label;
                _loc_4.text = String((param2 + 1));
                _loc_5.text = _loc_3.roleName;
                _loc_6.text = _loc_3.killnum;
            }
            return;
        }// end function

        public function destroyShow(param1:Dictionary) : void
        {
            return;
        }// end function

        public function initEvent() : void
        {
            btn_tuichu.clickHandler = new Handler(this.doTuichu);
            xunzhao.clickHandler = new Handler(this.toXunZhao);
            return;
        }// end function

        private function toXunZhao() : void
        {
            var _loc_1:* = ConfigDictionary.data.sysnpc[257];
            ModelProxy.change("zone", "autoMove", {x:_loc_1.x, y:_loc_1.y, tostageid:_loc_1.stageid, onhorse:false});
            return;
        }// end function

        protected function changeShow(event:MouseEvent) : void
        {
            return;
        }// end function

        private function doTuichu() : void
        {
            ModelProxy.change("zone", "exitInstance", null);
            return;
        }// end function

        public function removeEvent() : void
        {
            return;
        }// end function

    }
}
